package com.sskj.one.mine;

import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.one.bean.AgreeBean;
import com.sskj.one.bean.GouhuiBean;
import com.sskj.one.bean.TongdaoBean;
import com.sskj.one.presenter.BasePresenter;

import java.util.List;

/**
 * @author Hey
 * Create at  2019/05/22
 */
class HuiPresenter extends BasePresenter<HuiActivity> {


    public void getAgree(String type) {
        httpService.getAgree(type)
                .tag(this)
                .execute(new JsonCallBack<HttpData<AgreeBean>>(this) {
                    @Override
                    public void onHTTPSuccess(HttpData<AgreeBean> data) {

                        mView.getAgreeOK(data.getData());
                    }
                });
    }


    public void getRechargeInfo() {
        httpService.getRechargeInfo()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<String>>>() {
                    @Override
                    public void onHTTPSuccess(HttpData<List<String>> data) {
                        mView.getChargeInfoOK(data.getData());
                    }
                });
    }

    public void getTongdaos(boolean showLoading) {
        httpService.getTongdaos()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<TongdaoBean>>>(showLoading ? this : null) {
                    @Override
                    public void onHTTPSuccess(HttpData<List<TongdaoBean>> data) {
                        mView.getTongdaosOK(data.getData());
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }

    public void createRechargeOrder(String gouHuiMOney, String tongdao) {
        httpService.createRechargeOrder(gouHuiMOney, tongdao)
                .tag(this)
                .execute(new JsonCallBack<HttpData<GouhuiBean>>(this) {
                    @Override
                    public void onHTTPSuccess(HttpData<GouhuiBean> data) {
                        data.getData().setZftd(tongdao);
                        mView.createRechargeOK(data.getData());
                    }
                });
    }

    public void gouhui(String money, String pwd, String payway, String username, String wechat, String alipay, String bank, String branch, String bankCard) {
        httpService.gouhui(money, MD5Util.getFiveMd5Value(pwd), payway, username, wechat, alipay, bank, branch, bankCard)
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onHTTPSuccess(HttpData data) {
                        mView.gouhuiOK();

                    }
                });
    }
}
